package com.mzj.saas.mservice.code.controller;

import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.code.service.BusinessCodeService;
import com.mzj.saas.mservice.code.vo.BusinessCodeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 代付、合同二维码
 */
@Controller
@RequestMapping("/code")
public class BusinessCodeController {
	@Autowired
	private BusinessCodeService businessCodeService;

	/**
	 * 保存记录
	 * 
	 * @param accessToken
	 * @param vo
	 * @return
	 * @author shun
	 * @date 2021年6月24日
	 */
	@PostMapping("/qrcode")
	@ResponseBody
	public ResultBean<Object> code(@RequestHeader String accessToken, @RequestBody BusinessCodeVO vo) {
		return businessCodeService.code(accessToken, vo);
	}

	/**
	 * 查询缴费与代付信息
	 * 
	 * @param accessToken
	 * @param code
	 *            编码值/合同编码
	 * @param flag
	 *            类型：1编码 2合同编码
	 * @param type
	 *            操作类型：类型1合同 2公租房租金押金 3公租房其它缴费 4物业租金 5物业其它缴费 6维修 7生活缴费
	 * @return
	 * @author shun
	 * @date 2021年7月1日
	 */
	@RequestMapping("/{code}")
	@ResponseBody
	public ResultBean<Object> getCodeInfo(@RequestHeader String accessToken, @PathVariable String code,
			@RequestParam(name = "flag", required = false) Integer flag,
			@RequestParam(name = "type", required = false) Integer type) {
		return businessCodeService.getCodeInfo(accessToken, code, flag, type);
	}
}
